package com.lingyi.algorithm.lab2;

import cn.hutool.core.collection.CollUtil;

import java.util.ArrayList;

/**
 * 尾插
 * @author chenweilong
 * @email 1433471850@qq.com
 * @date 2020-08-19 17:05
 */
public class TailPut {


    public static void main(String[] args) {


        ArrayList<Integer> ints = CollUtil.newArrayList(1, 2, 3, 4, 5, 6);

        Node head = new Node();
        head.setT(-1);

        Node copy = head;
        for (Integer anInt : ints) {

            Node e;
            while (true) {

                if ((e = copy.getNext()) == null) {
                    Node newHead = new Node();
                    newHead.setT(anInt);
                    copy.setNext(newHead);
                    break;
                }
                copy = e;
            }

        }





        while (head.getNext() != null) {
            head = head.getNext();
            System.out.println(head.getT());
        }

    }


}
